package com.thread.xxstudy;

import java.util.Arrays;
import java.util.List;

/**
 *  写一个死锁
 */
public class DeadLock {

    static List<String> list1 = Arrays.asList("1", "2", "3");

    static List<String> list2 = Arrays.asList("4", "5", "6");
/*
    public static void main(String[] args) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                synchronized (list1) {
                    for (String i : list1) {
                        System.out.println(Thread.currentThread().getName() + "--" + i);
                    }
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    synchronized (list2) {
                        for (String r : list2) {
                            System.out.println(Thread.currentThread().getName() + "--" + r);
                        }
                    }


                }
            }
        }).start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                synchronized (list2) {
                    for (String i : list2) {
                        System.out.println(Thread.currentThread().getName() + "--" + i);
                    }


                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }

                    synchronized (list1) {
                        for (String r : list1) {
                            System.out.println(Thread.currentThread().getName() + "--" + r);
                        }
                    }


                }
            }
        }).start();
    }*/


}
